#include <windows.h>

#include "afxwin.h"
#include "afxsock.h"

#include "CSocket.hpp"

int main()
{
    WSADATA wsaData; 

    if (!AfxSocketInit(&wsaData))
    {
        AfxMessageBox("Error Unit");
        return -1;
    }

    CSocket sa;

    sa.Create();
    if (sa.Connect("smtp.yandex.ru", 25))
    {
        char buffer[255];
        int rc;

        rc = sa.Receive(buffer,sizeof(buffer));
        buffer[rc] = '\0';

        AfxMessageBox( buffer );

        char bufferhello[512];
        strcpy(bufferhello,"EHLO localhost\r\n");
        if (sa.Send(bufferhello,strlen(bufferhello))!=SOCKET_ERROR)
        {
            rc = sa.Receive(buffer,sizeof(buffer));
            buffer[rc] = '\0';

            AfxMessageBox( buffer );
        }
        else AfxMessageBox("Error Send");
    } 
    sa.Close();

    return 0;
}
